<!DOCTYPE html>
<html>
<head>
<title></title>

<?php 
session_start();
include_once '../gerenciadores/AutoloadGerenciadores.php';
include_once 'function/RecuperaCadastro.php';

__autoload("GerenciadorDeCoordenadores");
$gerCoord = new GerenciadorDeCoordenadores();

$tabCadastro = unserialize($_SESSION['cadastro']);
foreach ($tabCadastro as $cad){
	if($cad->getTipoVinculo()==4){	
 		$cadastro = $cad;
	}
}

$turma = $cadastro->getTurma();
$tabInstrutores = $gerCoord->visualizaTabelaInstrutores($turma);

if(isset($_POST['botao']) && $_POST['botao']=="Desistencia"){
	$tabIndex = $_POST['id'];
	
	foreach ($tabIndex as $index){
		$inscricao = $tabInstrutores[$index];
		$gerCoord->lancaDesistenciaInstrutor($inscricao);
		unset($tabInstrutores[$index]);
	}
}

if(isset($_POST['botao']) && $_POST['botao']=="Deleta"){
	$tabIndex = $_POST['id'];
	
	foreach ($tabIndex as $index){
		$inscricao = $tabInstrutores[$index];
		$gerCoord->excluiInscricao($inscricao);
		unset($tabInstrutores[$index]);
	}
}


?>
<link href="estilos/avaliacao.css" type="text/css" rel="stylesheet">
</head>
<body>
<form action="#" method="post">
<input type="submit" value="Desistencia" name="botao">
<input type ="submit" value="Deleta" name="botao">
	<table>
		<tr>
			<th>Sel</th><th>Nome</th><th>Disciplina</th><th>Tipo de Instrutor</th><th>Email</th><th>Telefone</th>
		</tr>
			<?php
				$i=0;
				 foreach ($tabInstrutores as $inscricao){
					$instrutor = $inscricao->getCadastro()->getPessoa();
					$disciplina = $inscricao->getDisciplina();					

					echo "<tr>";
					echo "<td>";
					echo "<input type='checkbox' value='".$i."' name='id[]'>";
					echo "</td><td>";
					echo $instrutor;
					echo "</td><td>";
					echo $disciplina;
					echo "</td><td>";
					echo $inscricao->getTipoInstrutor();
					echo "</td><td>";
					echo $instrutor->getEmail();
					echo "</td><td>";
					echo $instrutor->getTelefone();
					echo "</td>";
					echo "</tr>";
					$i++;
				 }
			?>
		</tr>
	</table>
</form>
	
</body>
</html>